package com.gdip.common.utils;

import java.net.URL;

public class UrlUtil {

    public static String extractFilename(String urlString) {
        try {
            URL url = new URL(urlString);
            String path = url.getPath();
            return path.substring(path.lastIndexOf('/') + 1);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static void main(String[] args) {
        String url = "http://hotbuilding-media.oss-cn-guangzhou.aliyuncs.com/avatar/my_image1701447925505.jpg?Expires=4855047925&OSSAccessKeyId=LTAI5tPbDkfkYZgCaXZxNNTc&Signature=2r1d%2F0J3bZcQsp2cJKakD0zabHQ%3D";
        String filename = extractFilename(url);
        System.out.println("Extracted filename: " + filename);
    }
}
